import pandas as pd
import plotly.express as px
df = pd.read_csv("https://covid.ourworldindata.org/data/owid-covid-data.csv")
html_path = r"/home/pi/HDD/webpages/charts/OWiD{html_file}.html"
folder_path = r"/home/pi/HDD/Datasets"
final_csv_path = r"{folder_path}/Covid19_OWiD.csv".format(folder_path=folder_path)
df.to_csv(final_csv_path,index=False)
fig = px.scatter(df[(df.iso_code=='IND')&(df.date>'2020-03-15')], x="date", y=["total_cases","total_deaths"], title='India Total Cases and Deaths').update_traces(mode='lines+markers')
fig.write_html(html_path.format(html_file = "IndiaTotalCasesAndDeaths"))
fig.show()
fig = px.scatter(df[(df.iso_code=='IND')&(df.date>'2020-03-15')], x="date", y=["new_cases","new_deaths"], title='India New Cases and Deaths').update_traces(mode='lines+markers')
fig.write_html(html_path.format(html_file = "IndiaNewCasesAndDeaths"))
fig.show()
fig = px.scatter(df[(df.continent=='Asia')&(df.date>'2020-03-15')], x="date", y=["total_cases"], title='Asia Total Cases',color='location').update_traces(mode='lines+markers')
fig.write_html(html_path.format(html_file = "AsiaTotalCases"))
fig.show()
fig = px.scatter(df[(df.continent=='North America')&(df.date>'2020-03-15')], x="date", y=["total_cases"], title='North America Total Cases',color='location').update_traces(mode='lines+markers')
fig.write_html(html_path.format(html_file = "NorthAmericaTotalCases"))
fig.show()
fig = px.scatter(df[(df.continent=='South America')&(df.date>'2020-03-15')], x="date", y=["total_cases"], title='South America Total Cases',color='location').update_traces(mode='lines+markers')
fig.write_html(html_path.format(html_file = "SouthAmericaTotalCases"))
fig.show()
fig = px.scatter(df[(df.continent=='Europe')&(df.date>'2020-03-15')], x="date", y=["total_cases"], title='Europe Total Cases',color='location').update_traces(mode='lines+markers')
fig.write_html(html_path.format(html_file = "EuropeTotalCases"))
fig.show()
fig = px.scatter(df[(df.continent=='Oceania')&(df.date>'2020-03-15')], x="date", y=["total_cases"], title='Oceania Total Cases',color='location').update_traces(mode='lines+markers')
fig.write_html(html_path.format(html_file = "OceaniaTotalCases"))
fig.show()
fig = px.scatter(df[(df.location.isin(['India','Canada','United States','Mexico','Brazil']))&(df.date>'2020-03-25')], x="date", y=["total_cases"], title='Total Cases Comparison Log scale',color='location',log_y=True).update_traces(mode='lines+markers')
fig.write_html(html_path.format(html_file = "TotalCasesComparisonLogScale"))
fig.show()
fig = px.scatter(df[(df.location.isin(['India','Canada','United States','Mexico','Brazil']))&(df.date>'2020-03-25')], x="date", y=["total_deaths"], title='Total Deaths Comparison Log scale',color='location',log_y=True).update_traces(mode='lines+markers')
fig.write_html(html_path.format(html_file = "TotalDeathsComparisonLogScale"))
fig.show()